<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>业务数据流程权限关系</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<form id="formSet1">
		<div class="fieldset1 tabel_col clearFix">
			<div class="fieldBox col_100">
				<div class="label">可支持流程</div>
				<div class="field">
					<input type="text" id="pDefKey" name="pDefKey" ltype="combobox" validate="{required:true}" placeholder="请选择"/>
				</div>
			</div>
		</div>
		<div class="btnsBox">
			<c:if test="${saveBizFlowRl == 1 }">
				<span id="saveBtn1" class="sq-button sq-button-round" onclick="add();">保存</span>
			</c:if>
			<input name="dataId" id="dataId" type="hidden" value="${dataId }">
			<input name="tabNm" id="tabNm" type="hidden" value="${tabNm }">
			<input name="codeGrpCd" id="codeGrpCd" type="hidden" value="${codeGrpCd }">
		</div>
	</form>
</div>

<script type="text/javascript">
$(function(){
	var _kvListJSON = ${kvListJSON};
	$("#pDefKey").ligerComboBox({ isShowCheckBox: true, isMultiSelect: true,
        data: _kvListJSON,
        valueField: 'key',
        textField:'value'
    });
	$('#formSet1').ligerForm({
        validate : true
	});
	initData();
	var saveBizFlowRl = '${saveBizFlowRl}';
	if(saveBizFlowRl!=1){
		liger.get("pDefKey").setDisabled();
	}
});
	function add(){
		var form = liger.get("formSet1");
		var data = form.getData();
		data["dataId"] = $("#dataId").val();
		data["tabNm"] = $("#tabNm").val();
		data["codeGrpCd"] = $("#codeGrpCd").val();
		var url = '<%=path%>/bizflow/sysBizFlowRl/addAndApply.do';
		var wait_dialog;
	    $.ajax({
			type: 'post',
			dataType:'json',
			data:data,
			url: url,
			beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
			success:function(msg){
				 wait_dialog.close();
				 if(msg.success == 1){
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 }else{
					 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
				 }
			}
		});
	}
	function initData(){
		var dataId = $("#dataId").val();
		var tabNm = $("#tabNm").val();
		var codeGrpCd = $("#codeGrpCd").val();
		if(!dataId || !tabNm || !codeGrpCd){
			//chahgeItemStatus(true);
			return;
		}
    	var _url = '<%=path%>/bizflow/sysBizFlowRl/getBizFlowRl.do';
    	$.ajax({
    		type: 'get',
    		dataType:'json',
    		data:{
    			dataId : dataId,
    			tabNm : tabNm,
    			codeGrpCd : codeGrpCd    			  	
    			},
    		url: _url,
    		success:function(msg){
    			 if(msg.success == 1){
    				 setData(msg.data);//设置数据
    				 console.log(msg.data);
    			 }else{
    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
    			 }
    		}
    	});
   	}
		
	function setData(data){
		$("#pDefKey").ligerGetComboBoxManager().selectValue(data);
		$("#pDefKey").ligerGetComboBoxManager().updateStyle();
	}
</script>

</body>
</html>
